<script>
	import {
		mapActions,
		mapMutations
	} from 'vuex'
	import {
		getConfig
	} from '@/api/app'
	import {
		setTabbar,
		strToParams
	} from '@/utils/tools'
	import {
		bindSuperior
	} from '@/api/user'
	import {INVITE_CODE} from '@/config/cachekey'
	import Cache from '@/utils/cache'
	export default {
		onLaunch: function(options) {
			// 获取配置
			this.getConfigFun()
			if(this.isLogin){
				this.getUser()
		    }
			this.getSystemInfo()
		},
		onShow: function(options) {
			this.bindCode(options)
		},
		onHide: function() {

		},
		methods: {
			...mapActions(['getSystemInfo', 'getUser', 'wxShare','initLocationFunc']), //
			...mapMutations(['setConfig']),
			async getConfigFun() {
				const {
					code,
					data
				} = await getConfig()
				if (code == 1) {
					this.setConfig(data)
					if(data.is_open_nearby) {
						// 获取定位
						// this.initLocationFunc()
						console.log(' 能力')
					}
					setTabbar()
					// 防止第一次调用时拿不到数据
					this.wxShare()
				}

			},
			async bindCode(options) {
				if(!options.query) return
				let invite_code = options.query.invite_code || strToParams(decodeURIComponent(options.query.scene))
					.invite_code
				if (invite_code) {
					const {
						data,
						code
					} = await bindSuperior({
						code: invite_code
					})
					if (code == -1) {
						Cache.set(INVITE_CODE, invite_code)
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	@import 'styles/common.scss';
	@import "components/uview-ui/index.scss";
	.iconfont {
		font-family: "iconfont" !important;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-webkit-text-stroke-width: 0.2px;
		-moz-osx-font-smoothing: grayscale;
	}
	/* http: */
	@font-face {
	  font-family: 'iconfont';  /* Project id 3996677 */
	  src: url('http://at.alicdn.com/t/c/font_3996677_lwc1rlp1dch.woff2?t=1686651628580') format('woff2'),
	       url('http://at.alicdn.com/t/c/font_3996677_lwc1rlp1dch.woff?t=1686651628580') format('woff'),
	       url('http://at.alicdn.com/t/c/font_3996677_lwc1rlp1dch.ttf?t=1686651628580') format('truetype');
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.btn-hover{
		background: transparent;
	}
	.clearfix:after {
	    content: ".";
	    display: block;
	    clear: both;
	    visibility: hidden;
	    height: 0;
	    font-size: 0;
	}
	.ellipsis{
	  overflow: hidden;
	  white-space: nowrap;
	  text-overflow: ellipsis;
	}
	/*每个页面公共css */
		
	
	/* 中心水平两端对齐 */
	.flex-s {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	
	/* 中心水平居右对齐 */
	.flex-end {
		display: flex;
		/* align-items: center; */
		justify-content: flex-end;
	}
	
	/* 中心水平居左对齐 */
	.flex-start {
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}
	
	/* 中心水平居中对齐 */
	.flex-center {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.margin30{
		margin: 0 30rpx;
	}
	.bor-ra{
		border-radius: 16rpx;
	}
	/* 底部提交按钮 */
	.submit-s {
		text-align: center;
		color: #ffffff;
		padding: 24rpx;
		font-size: 38rpx;
		border-radius: 30rpx;
		background-color: #216bbf;
		margin: 70rpx 36rpx ;
	}
	.ellipsis01,
	.ellipsis02,
	.ellipsis03,
	.ellipsis04 {
		width: 100%;
		overflow: hidden;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
	
	.ellipsis01 {
		-webkit-line-clamp: 1;
	}
	
	.ellipsis02 {
		-webkit-line-clamp: 2;
	}
	
	.ellipsis03 {
		-webkit-line-clamp: 3;
	}
	
	.ellipsis04 {
		-webkit-line-clamp: 4;
	}
</style>
